from zeus.operation_service.app.proxy.asset import AssetProxy
from zeus.operation_service.app.core.framework.common.constant import TaskType

from vulcanus.log.log import LOGGER


class AssetDao:
    task_type_dir = {
        TaskType.HEALTH_CHECK: 'healthcheck',
        TaskType.DATA_COLLECT: 'datacollection'
    }

    @staticmethod
    def get_assets_with_task_type(task_type):
        asset_list = list()
        asset_proxy = AssetProxy()
        asset_proxy.connect()
        assets = asset_proxy.get_all_asset()
        if task_type == 'all':
            LOGGER.info("get all assets")
            return assets
        LOGGER.info(f"get {task_type} assets")
        for asset in assets:
            support_type = asset.support_type
            support_type_list = support_type.split('|')
            if task_type in support_type_list:
                asset_list.append(asset)
        return asset_list
